<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleleaf.org">
<head th:insert="base">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" action="" method="post">
            <div class="layui-form-item">
                <input type="hidden" id="id" name="id"/>
                <label for="oldPassword" class="layui-form-label">
                    旧密码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="oldPassword" name="oldPassword" minlength="3" maxlength="20" lay-verify="range"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="newPaword" class="layui-form-label">
                    新密码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="newPaword" name="newPaword" minlength="3" maxlength="20" lay-verify="range"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="confirmPassword" class="layui-form-label">
                    再次确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="confirmPassword" name="confirmPassword" minlength="3" maxlength="20" lay-verify="range"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="edit" lay-submit="">
                    确认修改
                </button>
            </div>
        </form>
    </div>
</div>
<script th:inline="javascript">
    layui.use(['form','jquery','validate','tool'], function(){
        var form = layui.form;
        var $ = layui.jquery;
        var validate = layui.validate;
        var tool = layui.tool;
        var baseUrl = "/back/adminInfo";
        var id = [[${id}]];

        init_form();

        /**
         * 初始化页面
         */
        function init_form() {
            $("#id").val(id);
        }

        //添加表单校验
        form.verify(validate);

        //监听提交
        form.on('submit(edit)', function(data){
            var res = tool.submit(baseUrl + '/editpassword',data.field);
            if(res.code == return_200){
                layer.msg(res.msg, {
                        icon: msg.success,
                        time: 2000
                    },
                    function(){
                        xadmin.close();
                    }
                );
            }else {
                layer.msg(res.msg, {
                        icon: msg.error,
                        time: 2000
                    },
                    function(){
                        xadmin.close();
                    }
                );
            }
            return false;
        });
        
    });
</script>
</body>
</html>